package com.example.victory.entity.companyEntity;

import com.example.victory.swagger.model.Customer;
import com.example.victory.swagger.model.CustomerType;
import com.example.victory.swagger.model.RiskRatingEnum;
import com.cgws.fintech.sdk.common.utils.DateHelper;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;

import java.text.ParseException;
import java.util.Date;

@Data
@Slf4j
public class CustomerEntity extends Customer {
    private Integer gxlx;
    private String gxName;
    private CustomerType gxType;
    private Integer fxcsnl;
    //private Double zc;
    //private Double fz;
    private Integer pcrq;
    public Customer toCustomer() {
//        if (gxlx != null) {
//            switch (gxlx) {
//                case 1:
//                    this.gxType = CustomerType.SERVICE;
//                    break;
//                case 2:
//                    this.gxType = CustomerType.SIGN;
//                    break;
//                case 3:
//                    this.gxType = CustomerType.SERVICE_ASSIST;
//                    break;
//                case 10:
//                    this.gxType = CustomerType.DEVELOP;
//                    break;
//                case 11:
//                    this.gxType = CustomerType.DEVELOP_MARGIN;
//                    break;
//                case 20:
//                    this.gxType = CustomerType.RECOMMEND;
//                    break;
//                default:
//                    break;
//            }
//            if (this.gxType != null) {
//                this.setTypes(new ArrayList<>());
//                CustomerTypeName typeName = new CustomerTypeName();
//                typeName.setName(this.gxName);
//                typeName.setType(this.gxType);
//                this.getTypes().add(typeName);
//                this.gxType = null;
//                this.gxName = null;
//                this.gxlx = null;
//            }
//        }


        if (pcrq != null) {
            try {
                Date date = DateHelper.parseDateYYYYMMDD(String.valueOf(pcrq));
                String value = DateHelper.getDate(date);
                this.setRiskRatingDate(value);
                pcrq = null;
            } catch (ParseException ex) {
                log.error(ex.getMessage() + "," + pcrq, ex);
            }
        }

        if (fxcsnl != null) {
            switch (fxcsnl) {
                case 1:
                    this.setRiskRating(RiskRatingEnum.CONSERVATIVE);
                    break;
                case 2:
                    this.setRiskRating(RiskRatingEnum.CAUTIOUS);
                    break;
                case 3:
                    this.setRiskRating(RiskRatingEnum.DOVISH);
                    break;
                case 4:
                    this.setRiskRating(RiskRatingEnum.ACTIVE);
                    break;
                case 5:
                    this.setRiskRating(RiskRatingEnum.RADICAL);
                    break;
                default:
                    break;
            }
            if (this.getRiskRating() != null) {
                this.fxcsnl = null;
            }
        }
        return this;
    }
}
